package com.sgb.knowledgeshare.view.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.knowledgeshare.BR;
import com.sgb.knowledgeshare.R;
import com.sgb.knowledgeshare.entity.FollowListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.DateUtils;
import java.util.List;

/**
 * Created by fq on 2020/9/24 0024
 * Description：
 */
public class MagessFansAdapter extends BaseRecycleAdapter<FollowListEntity.RecordsBean> {

    public MagessFansAdapter(Context context, List<FollowListEntity.RecordsBean> datas) {
        super(context, R.layout.item_magess_fans, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, FollowListEntity.RecordsBean recordsBean) {
        holder.setBinding(BR.viewModel, recordsBean);
        ImageView fanslogos = holder.itemView.findViewById(R.id.fans_logo);
        TextView fansnames = holder.itemView.findViewById(R.id.fans_name);
        TextView fanstimes = holder.itemView.findViewById(R.id.fans_time);
        TextView fansstates = holder.itemView.findViewById(R.id.fans_state);
        Glide.with(context).load(recordsBean.getPhoto())
                .apply(RequestOptions.bitmapTransform(new CircleCrop()).placeholder(R.mipmap.share_def_photo))
                .into(fanslogos);
        fansnames.setText(recordsBean.getName() + "关注了你");
        fanstimes.setText(DateUtils.getDayUtils(recordsBean.getUpdateTime()));
        int isFollow = recordsBean.getIsFollow();
        switch (isFollow) {
            case 0://未关注
                break;
            case 1://已关注
                fansstates.setBackground(context.getResources().getDrawable(R.drawable.bg_item_report_type_select));
                fansstates.setText("已关注");
                break;
            case 2://相互关注
                fansstates.setBackground(context.getResources().getDrawable(R.drawable.bg_item_share_type_normal));
                fansstates.setText("互相关注");
                break;
        }
        //       关注状态请求参数
        fansstates.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fensData.fens(recordsBean.getUserNo());
            }
        });
    }

    private FensData fensData;

    public void setFensData(FensData fensData) {
        this.fensData = fensData;
    }

    public interface FensData {
        void fens(String UserNo);
    }

}
